//
//  CheXianViewController.m
//  YaDiuDiu
//
//  Created by 欧洪飞 on 2017/8/31.
//  Copyright © 2017年 jy. All rights reserved.
//

#import "CheXianViewController.h"

#import "CLBXView.h"
@interface CheXianViewController ()<UIScrollViewDelegate>
{
    CLBXView *view;
    UILabel *labPrice;
}

@property (nonatomic,assign)NSInteger str1;
@property (nonatomic,assign)NSInteger str2;
@property (nonatomic,assign)NSInteger str3;
@property (nonatomic,assign)NSInteger str4;
@property (nonatomic,assign)NSInteger str5;
@property (nonatomic,assign)NSInteger str6;
@property (nonatomic,assign)NSInteger str7;
@property (nonatomic,assign)NSInteger str8;
@property (nonatomic,assign)NSInteger str9;
@property (nonatomic,assign)NSInteger str10;


@end

@implementation CheXianViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    [self setBGColor];
    [self showNav:@"车辆保险"];
    [self loadUI];
}

- (void)loadUI{
    UIView *bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, ScreenHeight-50, ScreenWidth, 50)];
    [self.view addSubview:bottomView];
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame = CGRectMake(ScreenWidth/3*2, 0, ScreenWidth/3, 50);
    btn.backgroundColor = [UIColor redColor];
    [btn setTitle:@"报价" forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(clickBJ) forControlEvents:UIControlEventTouchUpInside];
    [bottomView addSubview:btn];
    
    UILabel *lab1 = [[UILabel alloc] init];
    lab1.text = @"车险参考报价:";
    lab1.font = [UIFont systemFontOfSize:15.0];
    [bottomView addSubview:lab1];
    [lab1 makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(bottomView.left).offset(16);
        make.centerY.equalTo(bottomView.centerY);
    }];
    
    labPrice = [[UILabel alloc] init];
    labPrice.text = @"2222";
    labPrice.hidden = YES;
    labPrice.textColor = [UIColor redColor];
    labPrice.font = [UIFont boldSystemFontOfSize:19.0];
    [bottomView addSubview:labPrice];
    [labPrice makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(lab1.right);
        make.centerY.equalTo(lab1.centerY);
    }];
    
    UIScrollView *sclView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 64, ScreenWidth, ScreenHeight-64-50)];
    sclView.contentSize = CGSizeMake(ScreenWidth, 880);
    sclView.delegate = self;
    [self.view addSubview:sclView];
    
    view = [[[NSBundle mainBundle] loadNibNamed:@"CLBXView" owner:nil options:nil] lastObject];
    view.frame = CGRectMake(0, 0, ScreenWidth, 880);
    [sclView addSubview:view];
    
    [view.btn1 addTarget:self action:@selector(click1) forControlEvents:UIControlEventTouchUpInside];
    [view.btn2 addTarget:self action:@selector(click2) forControlEvents:UIControlEventTouchUpInside];
    [view.btn3 addTarget:self action:@selector(click3) forControlEvents:UIControlEventTouchUpInside];
    [view.btn4 addTarget:self action:@selector(click4) forControlEvents:UIControlEventTouchUpInside];
    [view.btn5 addTarget:self action:@selector(click5) forControlEvents:UIControlEventTouchUpInside];
    [view.btn6 addTarget:self action:@selector(click6) forControlEvents:UIControlEventTouchUpInside];
    [view.btn7 addTarget:self action:@selector(click7) forControlEvents:UIControlEventTouchUpInside];
    [view.btn8 addTarget:self action:@selector(click8) forControlEvents:UIControlEventTouchUpInside];
    [view.btn9 addTarget:self action:@selector(click9) forControlEvents:UIControlEventTouchUpInside];
    [view.btn10 addTarget:self action:@selector(click10) forControlEvents:UIControlEventTouchUpInside];
    [view.btn11 addTarget:self action:@selector(click11) forControlEvents:UIControlEventTouchUpInside];
    [view.btn12 addTarget:self action:@selector(click12) forControlEvents:UIControlEventTouchUpInside];
    [view.btn13 addTarget:self action:@selector(click13) forControlEvents:UIControlEventTouchUpInside];
    [view.btn14 addTarget:self action:@selector(click14) forControlEvents:UIControlEventTouchUpInside];
    [view.btn15 addTarget:self action:@selector(click15) forControlEvents:UIControlEventTouchUpInside];
    [view.btn16 addTarget:self action:@selector(click16) forControlEvents:UIControlEventTouchUpInside];
    
    
    view.view1.userInteractionEnabled = YES;
    view.view2.userInteractionEnabled = YES;
    view.view3.userInteractionEnabled = YES;
    view.view4.userInteractionEnabled = YES;
    view.view5.userInteractionEnabled = YES;
    view.view6.userInteractionEnabled = YES;
    view.view7.userInteractionEnabled = YES;
    view.view8.userInteractionEnabled = YES;
    view.view9.userInteractionEnabled = YES;
    view.view10.userInteractionEnabled = YES;
    
    UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(click17)];
    [view.view1 addGestureRecognizer:tap1];
    UITapGestureRecognizer *tap2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(click18)];
    [view.view2 addGestureRecognizer:tap2];
    
    UITapGestureRecognizer *tap3 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(click19)];
    [view.view3 addGestureRecognizer:tap3];
    
    UITapGestureRecognizer *tap4 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(click20)];
    [view.view4 addGestureRecognizer:tap4];
    
    UITapGestureRecognizer *tap5 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(click21)];
    [view.view5 addGestureRecognizer:tap5];
    
    UITapGestureRecognizer *tap6 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(click22)];
    [view.view6 addGestureRecognizer:tap6];
    UITapGestureRecognizer *tap7 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(click23)];
    [view.view7 addGestureRecognizer:tap7];
    
    UITapGestureRecognizer *tap8 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(click24)];
    [view.view8 addGestureRecognizer:tap8];
    
    UITapGestureRecognizer *tap9 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(click25)];
    [view.view9 addGestureRecognizer:tap9];
    UITapGestureRecognizer *tap10 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(click26)];
    [view.view10 addGestureRecognizer:tap10];
    
    view.imageView1.tag = 1;
    view.imageView2.tag = 1;
    view.imageView3.tag = 1;
    view.imageView4.tag = 1;
    view.imageView5.tag = 1;
    view.imageView6.tag = 1;
    view.imageView7.tag = 1;
    view.imageView8.tag = 1;
    view.imageView9.tag = 1;
    view.imageView10.tag = 1;
    
    
}
//报价
- (void)clickBJ{
    NSInteger a = _str1+_str2+_str3+_str4+_str5+_str6+_str7+_str8+_str9+_str10;
    labPrice.text = [NSString stringWithFormat:@"%li元",a];
    labPrice.hidden = NO;
}

- (void)click1{
    [view.btn1 setImage:[UIImage imageNamed:@"勾"] forState:UIControlStateNormal];
    [view.btn2 setImage:[UIImage imageNamed:@"椭圆-2-拷贝"] forState:UIControlStateNormal];
    _str1 = 950;
}

- (void)click2{
    [view.btn1 setImage:[UIImage imageNamed:@"椭圆-2-拷贝"] forState:UIControlStateNormal];
    [view.btn2 setImage:[UIImage imageNamed:@"勾"] forState:UIControlStateNormal];
    _str1 = 1100;
}

- (void)click3{
    [view.btn3 setImage:[UIImage imageNamed:@"勾"] forState:UIControlStateNormal];
    [view.btn4 setImage:[UIImage imageNamed:@"椭圆-2-拷贝"] forState:UIControlStateNormal];
    [view.btn5 setImage:[UIImage imageNamed:@"椭圆-2-拷贝"] forState:UIControlStateNormal];
    [view.btn6 setImage:[UIImage imageNamed:@"椭圆-2-拷贝"] forState:UIControlStateNormal];
    _str2 = 877;
}

- (void)click4{
    [view.btn3 setImage:[UIImage imageNamed:@"椭圆-2-拷贝"] forState:UIControlStateNormal];
    [view.btn4 setImage:[UIImage imageNamed:@"勾"] forState:UIControlStateNormal];
    [view.btn5 setImage:[UIImage imageNamed:@"椭圆-2-拷贝"] forState:UIControlStateNormal];
    [view.btn6 setImage:[UIImage imageNamed:@"椭圆-2-拷贝"] forState:UIControlStateNormal];
    _str2 = 1077;
}

- (void)click5{
    [view.btn3 setImage:[UIImage imageNamed:@"椭圆-2-拷贝"] forState:UIControlStateNormal];
    [view.btn4 setImage:[UIImage imageNamed:@"椭圆-2-拷贝"] forState:UIControlStateNormal];
    [view.btn5 setImage:[UIImage imageNamed:@"勾"] forState:UIControlStateNormal];
    [view.btn6 setImage:[UIImage imageNamed:@"椭圆-2-拷贝"] forState:UIControlStateNormal];
    _str2 = 1472;
}

- (void)click6{
    [view.btn3 setImage:[UIImage imageNamed:@"椭圆-2-拷贝"] forState:UIControlStateNormal];
    [view.btn4 setImage:[UIImage imageNamed:@"椭圆-2-拷贝"] forState:UIControlStateNormal];
    [view.btn5 setImage:[UIImage imageNamed:@"椭圆-2-拷贝"] forState:UIControlStateNormal];
    [view.btn6 setImage:[UIImage imageNamed:@"勾"] forState:UIControlStateNormal];
    _str2 = 1917;
}
//车上人员
- (void)click7{
    [view.btn7 setImage:[UIImage imageNamed:@"勾"] forState:UIControlStateNormal];
    [view.btn8 setImage:[UIImage imageNamed:@"椭圆-2-拷贝"] forState:UIControlStateNormal];
    [view.btn9 setImage:[UIImage imageNamed:@"椭圆-2-拷贝"] forState:UIControlStateNormal];
    [view.btn10 setImage:[UIImage imageNamed:@"椭圆-2-拷贝"] forState:UIControlStateNormal];
    _str5 = 2*50;
}

- (void)click8{
    [view.btn7 setImage:[UIImage imageNamed:@"椭圆-2-拷贝"] forState:UIControlStateNormal];
    [view.btn8 setImage:[UIImage imageNamed:@"勾"] forState:UIControlStateNormal];
    [view.btn9 setImage:[UIImage imageNamed:@"椭圆-2-拷贝"] forState:UIControlStateNormal];
    [view.btn10 setImage:[UIImage imageNamed:@"椭圆-2-拷贝"] forState:UIControlStateNormal];
    _str5 = 4*50;
}

- (void)click9{
    [view.btn7 setImage:[UIImage imageNamed:@"椭圆-2-拷贝"] forState:UIControlStateNormal];
    [view.btn8 setImage:[UIImage imageNamed:@"椭圆-2-拷贝"] forState:UIControlStateNormal];
    [view.btn9 setImage:[UIImage imageNamed:@"勾"] forState:UIControlStateNormal];
    [view.btn10 setImage:[UIImage imageNamed:@"椭圆-2-拷贝"] forState:UIControlStateNormal];
    _str5 = 5*50;
}

- (void)click10{
    [view.btn7 setImage:[UIImage imageNamed:@"椭圆-2-拷贝"] forState:UIControlStateNormal];
    [view.btn8 setImage:[UIImage imageNamed:@"椭圆-2-拷贝"] forState:UIControlStateNormal];
    [view.btn9 setImage:[UIImage imageNamed:@"椭圆-2-拷贝"] forState:UIControlStateNormal];
    [view.btn10 setImage:[UIImage imageNamed:@"勾"] forState:UIControlStateNormal];
    _str5 = 7*50;
}
//国产
- (void)click11{
    [view.btn11 setImage:[UIImage imageNamed:@"勾"] forState:UIControlStateNormal];
    [view.btn12 setImage:[UIImage imageNamed:@"椭圆-2-拷贝"] forState:UIControlStateNormal];
    NSInteger p = [view.textPrice.text integerValue];
    _str8 = p*10000*(0.15/100);
}

- (void)click12{
    [view.btn11 setImage:[UIImage imageNamed:@"椭圆-2-拷贝"] forState:UIControlStateNormal];
    [view.btn12 setImage:[UIImage imageNamed:@"勾"] forState:UIControlStateNormal];
    NSInteger p = [view.textPrice.text integerValue];
    _str8 = p*10000*(0.25/100);
}
//车身划痕
- (void)click13{
    [view.btn13 setImage:[UIImage imageNamed:@"勾"] forState:UIControlStateNormal];
    [view.btn14 setImage:[UIImage imageNamed:@"椭圆-2-拷贝"] forState:UIControlStateNormal];
    [view.btn15 setImage:[UIImage imageNamed:@"椭圆-2-拷贝"] forState:UIControlStateNormal];
    [view.btn16 setImage:[UIImage imageNamed:@"椭圆-2-拷贝"] forState:UIControlStateNormal];
    _str9 = 400;
}

- (void)click14{
    [view.btn13 setImage:[UIImage imageNamed:@"椭圆-2-拷贝"] forState:UIControlStateNormal];
    [view.btn14 setImage:[UIImage imageNamed:@"勾"] forState:UIControlStateNormal];
    [view.btn15 setImage:[UIImage imageNamed:@"椭圆-2-拷贝"] forState:UIControlStateNormal];
    [view.btn16 setImage:[UIImage imageNamed:@"椭圆-2-拷贝"] forState:UIControlStateNormal];
    _str9 = 570;
}

- (void)click15{
    [view.btn13 setImage:[UIImage imageNamed:@"椭圆-2-拷贝"] forState:UIControlStateNormal];
    [view.btn14 setImage:[UIImage imageNamed:@"椭圆-2-拷贝"] forState:UIControlStateNormal];
    [view.btn15 setImage:[UIImage imageNamed:@"勾"] forState:UIControlStateNormal];
    [view.btn16 setImage:[UIImage imageNamed:@"椭圆-2-拷贝"] forState:UIControlStateNormal];
    _str9 = 760;
}

- (void)click16{
    [view.btn13 setImage:[UIImage imageNamed:@"椭圆-2-拷贝"] forState:UIControlStateNormal];
    [view.btn14 setImage:[UIImage imageNamed:@"椭圆-2-拷贝"] forState:UIControlStateNormal];
    [view.btn15 setImage:[UIImage imageNamed:@"椭圆-2-拷贝"] forState:UIControlStateNormal];
    [view.btn16 setImage:[UIImage imageNamed:@"勾"] forState:UIControlStateNormal];
    _str9 = 1140;
}

//
- (void)click17{
    if (view.imageView1.tag == 1) {
        view.imageView1.image = [UIImage imageNamed:@"勾-(1)"];
        view.imageView1.tag = 2;
    }else{
        view.imageView1.image = [UIImage imageNamed:@"矩形-7"];
        view.imageView1.tag = 1;
    }
}

- (void)click18{
    if (view.imageView2.tag == 1) {
        view.imageView2.image = [UIImage imageNamed:@"勾-(1)"];
        view.imageView2.tag = 2;
    }else{
        view.imageView2.image = [UIImage imageNamed:@"矩形-7"];
        view.imageView2.tag = 1;
    }
}
//车损
- (void)click19{
    if (view.imageView3.tag == 1) {
        view.imageView3.image = [UIImage imageNamed:@"勾-(1)"];
        view.imageView3.tag = 2;
        NSInteger p = [view.textPrice.text integerValue];
        _str3 = 539+p*10000*(1.088/100);
        
    }else{
        view.imageView3.image = [UIImage imageNamed:@"矩形-7"];
        view.imageView3.tag = 1;
    }
    
}
//免赔
- (void)click20{
    if (view.imageView4.tag == 1) {
        view.imageView4.image = [UIImage imageNamed:@"勾-(1)"];
        view.imageView4.tag = 2;
        _str4 = (_str2+_str3)*0.2;
    }else{
        view.imageView4.image = [UIImage imageNamed:@"矩形-7"];
        view.imageView4.tag = 1;
    }
}

- (void)click21{
    if (view.imageView5.tag == 1) {
        view.imageView5.image = [UIImage imageNamed:@"勾-(1)"];
        view.imageView5.tag = 2;
    }else{
        view.imageView5.image = [UIImage imageNamed:@"矩形-7"];
        view.imageView5.tag = 1;
    }
}
//无过责任险
- (void)click22{
    if (view.imageView6.tag == 1) {
        view.imageView6.image = [UIImage imageNamed:@"勾-(1)"];
        view.imageView6.tag = 2;
        _str6 = _str2*0.2;
    }else{
        view.imageView6.image = [UIImage imageNamed:@"矩形-7"];
        view.imageView6.tag = 1;
        _str6 = 0;
    }
}
//自然
- (void)click23{
    if (view.imageView7.tag == 1) {
        view.imageView7.image = [UIImage imageNamed:@"勾-(1)"];
        view.imageView7.tag = 2;
        NSInteger p = [view.textPrice.text integerValue];
        _str7 = p * (0.15/100)*10000;
    }else{
        view.imageView7.image = [UIImage imageNamed:@"矩形-7"];
        view.imageView7.tag = 1;
        _str7 = 0;
    }
}

- (void)click24{
    if (view.imageView8.tag == 1) {
        view.imageView8.image = [UIImage imageNamed:@"勾-(1)"];
        view.imageView8.tag = 2;
    }else{
        view.imageView8.image = [UIImage imageNamed:@"矩形-7"];
        view.imageView8.tag = 1;
    }
}

- (void)click25{
    if (view.imageView9.tag == 1) {
        view.imageView9.image = [UIImage imageNamed:@"勾-(1)"];
        view.imageView9.tag = 2;
    }else{
        view.imageView9.image = [UIImage imageNamed:@"矩形-7"];
        view.imageView9.tag = 1;
    }
}
//全车盗险
- (void)click26{
    if (view.imageView10.tag == 1) {
        view.imageView10.image = [UIImage imageNamed:@"勾-(1)"];
        view.imageView10.tag = 2;
        NSInteger p = [view.textPrice.text integerValue];
        _str10 = 120+p*10000*(0.53/100);
    }else{
        view.imageView10.image = [UIImage imageNamed:@"矩形-7"];
        view.imageView10.tag = 1;
        _str10 = 0;
    }
}

-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
    [[UIApplication sharedApplication].keyWindow endEditing:YES];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
